package core

import (
	"gitee.com/hongzhaomin/gspring/iface"
)

func NewDefaultApplicationContext() *DefaultApplicationContext {
	defaultAppCtx := new(DefaultApplicationContext)
	defaultAppCtx.AbstractApplicationContext = NewAbstractApplicationContext(defaultAppCtx, nil)
	return defaultAppCtx
}

var _ iface.ApplicationContext = (*DefaultApplicationContext)(nil)

type DefaultApplicationContext struct {
	*AbstractApplicationContext

	beanFactory iface.ListableBeanFactory
}

func (my *DefaultApplicationContext) GetBeanFactory() iface.ListableBeanFactory {
	return my.beanFactory
}

func (my *DefaultApplicationContext) RefreshBeanFactory() {
	beanFactory := my.createBeanFactory()
	my.beanFactory = beanFactory
}

func (my *DefaultApplicationContext) createBeanFactory() *DefaultListableBeanFactory {
	return NewDefaultBeanFactory()
}
